/**
 * 系统平台
 * moonvip_admin
 * com.tz.web.diamondparmcalculation
 * DiamondParmCalculationController.java
 * 创建人:小胡
 * 时间：2017年03月03日 13:45:23
 *
 */
package com.tz.web.diamondparmcalculation;

import com.tz.auth.AuthPassport;
import com.tz.bean.DiamondParmCalculation;
import com.tz.bean.TzParams;
import com.tz.service.diamondparmcalculation.IDiamondParmCalculationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * 钻石估价参数管理web
 * DiamondParmCalculationController
 * 创建人:小胡
 * 时间：2017年03月03日 13:45:23
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("/admin/service/diamondparmcalculation")
public class DiamondParmCalculationController {
	
	@Autowired
	private IDiamondParmCalculationService diamondparmcalculationService;

	/*列表查询*/
	@AuthPassport
	@RequestMapping("/list")
	public String list(TzParams params){
		return "service/diamondparmcalculation/list";
	}

    /*模板页面*/
	@RequestMapping("/template")
	public String template(TzParams params ,Model model){
		params.setDeleteCode("001");
		model.addAttribute("datas", diamondparmcalculationService.findDiamondParmCalculations(params));
		model.addAttribute("itemCount", diamondparmcalculationService.count(params));
		return "service/diamondparmcalculation/template";
	}

	@AuthPassport
	@RequestMapping("/add")
	public String add(TzParams params,Model model){
		model.addAttribute("allLevel",diamondparmcalculationService.getAllLevel());
		model.addAttribute("allType",diamondparmcalculationService.getAllType());
		return "service/diamondparmcalculation/add";
	}

	@AuthPassport
	@RequestMapping(value = "/edit/{id}" ,method = RequestMethod.GET)
	public String edit(@PathVariable("id") Integer id , Model model){
		model.addAttribute("allLevel",diamondparmcalculationService.getAllLevel());
		model.addAttribute("allType",diamondparmcalculationService.getAllType());
		model.addAttribute("diamondparmcalculation",diamondparmcalculationService.getDiamondParmCalculation(id));
		return "service/diamondparmcalculation/edit";
	}

	@AuthPassport
	@ResponseBody
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	public String delete(TzParams params){
		diamondparmcalculationService.delete(params);
		return "success";
	}

    @ResponseBody
	@RequestMapping("/save")
	public int save(DiamondParmCalculation diamondparmcalculation){
		int n = diamondparmcalculationService.save(diamondparmcalculation);
		return n;
	}

	@ResponseBody
	@RequestMapping(value="/update")
	public int update(DiamondParmCalculation diamondparmcalculation){
		diamondparmcalculation.setUpdateTime(new Date());
		int n = diamondparmcalculationService.update(diamondparmcalculation);
		return n;
	}


	/**
	 * 钻石所有规格
	 * @param codevalue
	 * @return
	 */
    @ResponseBody
    @RequestMapping("/getAllspec")
    public List<HashMap<String,Object>> getAllspec(String codevalue){
	   return  diamondparmcalculationService.getAllspec(codevalue);
    }


}
